package com.jianhua.appmarket.common.base;

public class AppResponse<T> {

    private int code = 200;
    private String errMsg;
    private T body;
    private int total;

    public static AppResponse success(Object body){
        AppResponse response = new AppResponse();
        response.setBody(body);
        return response;
    }

    public static AppResponse fail(String errMsg){
        AppResponse response = new AppResponse();
        response.setCode(500);
        response.setErrMsg(errMsg);
        return response;
    }

    public static AppResponse fail(int code ,String errMsg){
        AppResponse response = new AppResponse();
        response.setCode(code);
        response.setErrMsg(errMsg);
        return response;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public void setErrMsg(String errMsg) {
        this.errMsg = errMsg;
    }

    public T getBody() {
        return body;
    }

    public void setBody(T body) {
        this.body = body;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }
}
